import { Popconfirm,message } from 'antd'
import { reqDeleteStuInfo } from '@/api'

interface Iprops {
  stuID: number
  handleFlag: any
}

function DeleteStu(props:Iprops) {
  // 删除操作
  const deleteStu = () => {
    reqDeleteStuInfo(props.stuID).then(res => {
      const {code, msg} = res.data
      if(code === 200) {
        message.success(msg)
      }
    })
    props.handleFlag() // 改变依赖更新父组件
  }

  return (
    <Popconfirm 
      title='确定删除此项？' 
      onCancel={() => console.log('用户取消删除')} 
      onConfirm={deleteStu}
    >
      <span className='inner_buttons'>删除</span>
    </Popconfirm>
  )
}

export default DeleteStu